package com.tbit.main.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 手机号码校验
 *
 * @author Leon
 * 2019年1月23日 下午3:56:48
 */
public class PhoneNumberUtil {

    /**
     * 手机号码校验
     *
     * @param phone
     * @return
     */
    public static boolean isPhone(String phone) {
        //String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(16[0,1,2,3,5,6,7,8])|(17[0,1,2,3,5,6,7,8])|(18[0-9])|(19[0-9]))\\d{8}$";
        String regex = "[0-9]{1,11}";
        if (phone.length() != 11) {
            return false;
        } else {
            Pattern p = Pattern.compile(regex);
            Matcher m = p.matcher(phone);
            boolean isMatch = m.matches();
            return isMatch;
        }
    }

    public static void main(String[] args) {
        System.out.println(isPhone("19161298573"));
    }

}
